library(igraph)
## Warning: package 'igraph' was built under R version 3.4.1
## 
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
library(dplyr)
## Warning: package 'dplyr' was built under R version 3.4.2
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:igraph':
## 
##     as_data_frame, groups, union
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
coffeeG05 = read_graph("Data/iGraphs/coffeeG05.gml", format = "gml")

tri = triangles(coffeeG05)
tri_df = matrix(names(tri), byrow = TRUE)
dim(tri_df) = c(3,nrow(tri_df)/3)
tri_df = data.frame(t(tri_df))
colnames(tri_df) = c("a","b","c")

DF = tri_df %>% filter(a == "Ethiopia:ETH" | b == "Ethiopia:ETH" | c == "Ethiopia:ETH")

for(i in 1:nrow(DF)){
        plot(induced_subgraph(coffeeG05, vids = as.character(unlist(DF[i,]))))
}